<template>
    <div>
        <my-loading-overlay :loading-overlay="loadingOverlay"></my-loading-overlay>
        <my-button-frame>
            <div class="d-inline-block mr-2">
                <v-btn @click="$router.push('/disk/collection')" outlined color="primary" height="40px">返回</v-btn>
            </div>
            <div class="d-inline-block">
                <my-new-link-btn @new-link-success="getLinkList()"></my-new-link-btn>
            </div>
        </my-button-frame>
        <my-link-list
                :link-list="linkList"
                @reset-link-list="getLinkList()"
        ></my-link-list>
    </div>
</template>

<script>
    import MyButtonFrame from "../../common/MyButtonFrame";
    import MyLinkList from "./MyLinkList";
    import MyLoadingOverlay from "../../common/MyLoadingOverlay";
    import MyNewLinkBtn from "./MyNewLinkBtn";
    export default {
        name: "Link",
        components: {MyNewLinkBtn, MyLoadingOverlay, MyLinkList, MyButtonFrame},
        created() {
            this.getLinkList();
        },
        data() {
            return {
                loadingOverlay: false,
                linkList: []
            }
        },
        methods: {
            getLinkList() {
                let _this = this;
                _this.loadingOverlay = true;
                _this._get({
                    url: 'system/collection/get-link-list',
                    params: {
                        cid: _this.cid
                    }
                }).then(rsp => {
                    _this.linkList = rsp.data;
                }).catch(error => {
                    console.log(error)
                    _this.$serverError();
                }).finally(() => {
                    _this.loadingOverlay = false;
                })
            }
        },
        computed: {
            cid() {
                return this.$route.query.cid;
            }
        }
    }
</script>

<style scoped>

</style>